package com.ktjy.ktmall.dao.impl;

import com.ktjy.ktmall.dao.BaseDao;
import com.ktjy.ktmall.dao.BrandItemDao;
import com.ktjy.ktmall.entity.BannerItem;
import com.ktjy.ktmall.entity.BrandItem;

import java.sql.SQLException;

/**
 * 品牌模块DAO接口实现类
 * @version v1.0
 * @Author 郴州科泰
 * @Create 2024-07-25 - 00:02
 */
public class BrandItemDaoImpl extends BaseDao implements BrandItemDao {

    /**
     * 根据品牌id查询品牌详情信息
     * @param id 品牌id
     * @return 返回查询到的品牌详情信息
     */
    @Override
    public BrandItem findById(int id) {
        BrandItem b = null;
        String sql = "select * from t_brand where `enabled` = 0 and `id` = ?";
        rs = super.executeQuery(sql, id);
        try {
            while (rs.next()) {
                b = new BrandItem(rs.getInt("id"),rs.getString("name"), rs.getString("logo_url"), rs.getInt("enabled"),rs.getString("create_time"), rs.getString("update_time"));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            super.closeAll(rs, pstmt, conn);
        }
        return b;
    }
}
